<template>
  <div id="OrdersCarrier">
    <g-details
      :detailData="inputData"
      :inputConfig="inputConfig"
      @pop="setdata"
    ></g-details>
  </div>
</template>

<script>
import baseMixin from "@/mixins/BaseMixin";

export default {
  name: "OrdersCarrier",
  mixins: [baseMixin],
  props: {
    inputData: {
      type: Object,
    },
  },
  data() {
    return {
      inputConfig: [
        {
          type: "input",
          label: this.$t('out.orderkey'),
          props: "orderkey",
          disabled: true,
        },
        {
          type: "table",
          label: this.$t('bill.carrierCode'),
          props: "carriercode",
          tableConfig: [
            {
              label: this.$t('config.shipper'),
              prop: "storerkey",
              input: "input",
            },
            {
              label: this.$t('config.company'),
              prop: "company",
              input: "input",
            },
            {
              label: this.$t('config.city'),
              prop: "city",
              input: "input",
            },
            {
              label: this.$t('config.provice'),
              prop: "state",
              input: "input",
            },
            {
              label: this.$t('config.postcode'),
              prop: "zip",
              input: "input",
            },
            {
              label: this.$t('config.contact'),
              prop: "contact",
              input: "input",
            },
            {
              label: this.$t('config.phone'),
              prop: "phone",
              input: "input",
            },
          ],
          url: `queryStorer/3/?/${this.$store.state.wms}`,
        },
        {
          type: "date",
          label: this.$t('in.arrivaldatetime'),
          props: "actualarrivaldate",
          disabled: true,
        },
        {
          type: "date",
          label: this.$t('in.actualdeparturedate'),
          props: "depdatetime",
        },
        {
          type: "date",
          label: this.$t('out.actualdelvdate'),
          props: "actualdelvdate",
        },
        {
          type: "date",
          label: this.$t('out.planneddelvdate'),
          props: "planneddelvdate",
        },
        {
          type: "date",
          label: this.$t('out.scheduleddelvdate'),
          props: "scheduleddelvdate",
        },
        {
          type: "input",
          label: this.$t('in.carriername'),
          props: "carriername",
          disabled: true,
        },
        {
          type: "input",
          label: this.$t('out.carrieraddress',{no:1}),
          props: "carrieraddress1",
          disabled: true,
        },
        {
          type: "input",
          label: this.$t('out.carrieraddress',{no:2}),
          props: "carrieraddress2",
          disabled: true,
        },
        {
          type: "input",
          label: this.$t('config.phone'),
          props: "carrierphone",
          disabled: true,
        },
        {
          type: "input",
          label: this.$t('config.city'),
          props: "carriercity",
          disabled: true,
        },
        {
          type: "input",
          label: this.$t('config.provice'),
          props: "carrierstate",
          disabled: true,
        },
        {
          type: "input",
          label: this.$t('config.postcode'),
          props: "carrierzip",
          disabled: true,
        },
        {
          type: "input",
          label: this.$t('bill.country'),
          props: "carriercountry",
        },
        {
          type: "input",
          label: this.$t('in.trailernumber'),
          props: "trailernumber",
        },
        {
          type: "input",
          label: this.$t('in.trailerdesc'),
          props: "description",
          disabled: true,
        },
        {
          type: "input",
          label: this.$t('in.trailerowner'),
          props: "trailerowner",
        },
        {
          type: "input",
          label: this.$t('in.drivername'),
          props: "drivername",
        },
        {
          type: "input",
          label: this.$t('out.pronumber'),
          props: "pronumber",
        },
        {
          type: "input",
          label: this.$t('out.rtxexpresskey'),
          props: "rtxexpresskey",
        },
      ],
    };
  },
  methods: {
    async setdata(data, close) {
      this.inputData.carriercode = data.storerkey;
      try {
        let res = await this.$api.get(`/po/detail/storerkey/${data.storerkey}`);
        
          this.inputData.carriername = res.bean.company;
          this.inputData.carrieraddress1 = res.bean.address1;
          this.inputData.carrieraddress2 = res.bean.address2;
          this.inputData.carriercity = res.bean.city;
          this.inputData.carrierstate = res.bean.state;
          this.inputData.carrierzip = res.bean.zip;
          this.inputData.carrierphone = res.bean.phone1;
          close(false);
        
      } catch (e) {
        this.$message.error(e);
      }
    },
  },
  mounted() {},
};
</script>

<style scoped></style>
